<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>修改密码</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" type="text/css" href="../assets/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="../assets/fonts/line-icons.css">
    <link rel="stylesheet" type="text/css" href="../assets/css/main.css">
    <link rel="stylesheet" type="text/css" href="../assets/css/responsive.css">
</head>
<body>
<div class="container-fluid">
    <div class="breadcrumb-wrapper row">
        <div class="col-12 col-lg-3 col-md-6">
            <h4 class="page-title">修改密码</h4>
        </div>
        <div class="col-12 col-lg-9 col-md-6">
            <ol class="breadcrumb float-right">
                <li class="active">个人信息</li>
                <li class="active"> / 修改密码</li>
            </ol>
        </div>
    </div>
</div>
<div class="container-fluid">
    <div class="row">
        <div class="col-12 grid-margin">
            <div class="card">
                <div class="card-header border-bottom">
                    <h4 class="card-title">修改密码</h4>
                </div>
                <div class="card-body">
                    <form class="form-sample">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">旧密码</label>
                                    <div class="col-sm-9">
                                        <input id="oldPassword" type="password" class="form-control">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">新密码</label>
                                    <div class="col-sm-9">
                                        <input id="newPassword" type="password" class="form-control">
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="col-sm-3 col-form-label">确认密码</label>
                                    <div class="col-sm-9">
                                        <input id="surePassword" type="password" class="form-control">
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="text-center">
                            <input class="btn btn-common mr-3" id="sureButton" value="确认"/>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../assets/js/jquery-min.js"></script>
<script src="../assets/js/bootstrap.min.js"></script>
<script src="../assets/js/jquery.bootstrap-growl.js"></script>
<script>
    $(function () {
        var ctx = window.parent.ctx;

        $("#sureButton").click(function () {
            var oldPassword = $("#oldPassword").val();
            var newPassword = $("#newPassword").val();
            var surePassword = $("#surePassword").val();

            if(newPassword==""||surePassword==""||oldPassword==""){
				$.bootstrapGrowl("密码不允许为空");
            }else if(newPassword!=surePassword){
				$.bootstrapGrowl("两次输入密码不一致");
			}else{
                $.ajax({
                    type: "post",
                    url: ctx+"/user/updatePassword",
                	xhrFields: {
                	    withCredentials: true
                	},
                    data: {oldPassword: oldPassword, newPassword: newPassword},
                    success: function (data) {
						$("#oldPassword").val("");
						$("#newPassword").val("");
						$("#surePassword").val("");
                        $.bootstrapGrowl(data);
                    }
                })
            }
        })
    })
</script>
</body>
</html>